<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  
<%@ page import="java.util.Map" %>  
<%@ page import="java.util.Set" %> 

 <% 
 	Map<Integer,String> idToCategoryDescriptionMap = (Map<Integer,String>) request.getAttribute("idToCategoryDescriptionMap");
 	Set<Integer> categoryIds = idToCategoryDescriptionMap.keySet();
 	Set<Integer> productCategoryIds = (Set<Integer>) request.getAttribute("productCategoryIds");
 	String description = (String) request.getAttribute("description");
 	String itemId = (String) request.getAttribute("itemId");
 	
 %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Категоризация</title>
<link rel="stylesheet" href="/Store/css/Administration.css" type="text/css">

</head>
<body>
<div class="container">
<form action="/Store/Categorize" method="post" autocomplete="off">

<div class="main">
	<h3> <%=description %></h3>
	<input type="text" style="display:none" name="itemId" value=<%=itemId%>>
</div>


<div class="main">
<h4> Добавяне към категории:</h4>
	<table class="center">
		
			
			<% for(int categoryId: categoryIds){
		   			if(!productCategoryIds.contains(categoryId)){%>
						<tr>
							<td>  <%=idToCategoryDescriptionMap.get(categoryId)%></td> 
							<td> <input type="checkbox" name="addToCategory[]" value=<%=categoryId%>> </td>
						</tr>
			<%}}%>
			
			
		
	</table>
</div>

<div class="main">
<h4> Премахване от категории: </h4>
<table class="center">
<%  for(int categoryId : productCategoryIds){ %>
	<tr>
		<td> <%=idToCategoryDescriptionMap.get(categoryId) %> </td>
		<td> <input type="checkbox" name="removeFromCategory[]" value=<%=categoryId %>> </td>
	
	</tr>	
		
		
<% } %>
</table>
</div>


<div class="main"> 
	<table class="center">
		<tr>
			<td> <input type="submit" value="Продължи"></td>
			<td class="cancel"> <a href="/Store/Supplier.html"> <button type="button"> Отмени </button> </a></td>
		</tr>
	</table>
</div>
</form>

</div>
</body>
</html>